class API {
  data = {
    getById: "GetModel",
    getModel: "GetModel",
    getList: "GetList",
    postCreate: "Create",
    create: "Create",
    postEdit: "Edit",
    edit: "Edit",
    deleteById: "Delete/",
    check: "Check/",
    up: "Up",
  };
  fullName = "";
  apiName = "";
  entity = "";
  action = "";
  // getModel = "";
  // getList = "";
  // create = "";
  // edit = "";
  // delete = "";
  constructor(apiName) {
    let arr = apiName.match(/\w+/g);
    if (arr[0] == "api") {
      this.entity = arr[1];
    } else {
      this.entity = arr[0];
    }
    this.apiName = `/api/${this.entity}/`;
    if (arr.length > 2) {
      this.action = arr[2];
      this.fullName = apiName;
    }
  }
  get getModel() {
    return this.apiName + "GetModel/";
  }
  get getList() {
    return this.apiName + this.data.getList;
  }
  set getList(value) {
    this.data.getList = value;
  }
  get up() {
    return this.apiName + this.data.up;
  }
  set up(value) {
    this.data.up = value;
  }
  get create() {
    return this.apiName + this.data.create;
  }
  set create(value) {
    this.data.create = value;
  }
  get check() {
    return this.apiName + this.data.check;
  }
  set check(value) {
    this.data.check = value;
  }
  get edit() {
    return this.apiName + this.data.edit;
  }
  get delete() {
    return this.apiName + "Delete/";
  }
  get getById() {
    return this.apiName + this.data.getById;
  }
  set getById(value) {
    this.data.getById = value;
  }
  get postCreate() {
    return this.apiName + this.data.postCreate;
  }
  set postCreate(value) {
    this.data.postCreate = value;
  }
  get postEdit() {
    return this.apiName + this.data.postEdit;
  }
  set postEdit(value) {
    this.data.postEdit = value;
  }
  get deleteById() {
    return this.apiName + this.data.deleteById;
  }
  set deleteById(value) {

    this.data.deleteById = value;
  }
}
// function API(apiName) {
//   let data = {
//     apiName: apiName,
//     getById: "GetModel",
//     getList: "GetList",
//     postCreate: "Create",
//     postEdit: "Edit",
//     deleteById: "Delete",
//   };
//   Object.defineProperties(this.data. {
//     getById: {
//       get() {
//         return data.apiName + data.getById;
//       },
//       set(value) {
//         return (data.getById = value);
//       },
//     },
//     getList: {
//       get() {
//         return data.apiName + data.getList;
//       },
//       set(value) {
//         data.getList = value;
//       },
//     },

//     postCreate: {
//       get() {
//         return data.apiName + data.postCreate;
//       },
//       set(value) {
//         data.postCreate = value;
//       },
//     },
//     postEdit: {
//       get() {
//         return data.apiName + data.postEdit;
//       },
//       set(value) {
//         data.postEdit = value;
//       },
//     },
//     deleteById: {
//       get() {
//         return data.apiName + data.deleteById;
//       },
//       set(value) {
//         data.deleteById = value;
//       },
//     },
//   });
// }
export default API;
